package com.itheima.dao;

import com.itheima.domain.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 陆小根
 * date: 2022/05/04
 * Description:
 */
@Mapper
public interface BookDao {

  //    @Insert("insert into tbl_book values(null,#{type},#{name},#{description})")
  @Insert("insert into tbl_book (type,name,description) values(#{type},#{name},#{description})")
  int save(Book book);

  @Update("update tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")
  int update(Book book);

  @Delete("delete from tbl_book where id = #{id}")
  int delete(Integer id);

  @Select("select * from tbl_book where id = #{id}")
  Book getById(Integer id);

  @Select("select * from tbl_book")
  List<Book> getAll();

}
